package coml.jiyun.hp.jiaohuafei;


import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import coml.jiyun.hp.jiaohuafei.ui.activity.ExchangeActivity;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private TextView tv;
    private EditText et;
    private Button btu_ok;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();

    }

    private void initView() {
        tv = (TextView) findViewById(R.id.tv);
        et = (EditText) findViewById(R.id.et);
        btu_ok = (Button) findViewById(R.id.btu_ok);

        btu_ok.setOnClickListener(this);
        tv.setText("首页");
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btu_ok:

                String string = et.getText().toString();
                if (!string.isEmpty()){
                    Intent intent = new Intent(this, ExchangeActivity.class);
                    intent.putExtra("name",string);
                    startActivity(intent);
                }else {
                    Toast.makeText(this, "不能为空", Toast.LENGTH_SHORT).show();
                }
                break;
        }
    }
}